<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.model.Department2"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>

<%
{
User registerUser = (User) session.getAttribute(Constants.SESSION_REGISTER_USER);
%>
<%
String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
Long depart1ID = 1L;
try {
	depart1ID = new Long(depart1IDStr);
} catch (Exception e) {
}

DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
List<Department2> depart2List = departmentDao.getDepartment2ListByDepartment1ID(depart1ID);
%>
<select id="depart2ID" onchange="refreshDepart3(getElementValueByID('depart1ID'), getElementValueByID('depart2ID'))">
	<%
	for (Department2 depart2 : depart2List) {
	%>
	<option value="<%=depart2.getId()%>" <%=(depart2.getId().equals(registerUser.getDepartment2ID())? "selected":"")%>><%=depart2.getDepartment2Name()%></option>
	<%
	}
	%>
</select>
<%
}
%>
<script type="text/javascript">
refreshDepart3(getElementValueByID('depart1ID'), getElementValueByID('depart2ID'));
</script>